﻿using System;

namespace ConsoleDemo.Data
{
    public class PersonShoe : IEquatable<PersonShoe>
    {
        public readonly Person Person;
        public readonly Shoe Shoe;

        public PersonShoe(Person person, Shoe shoe)
        {
            Person = person;
            Shoe = shoe;
        }

        public override int GetHashCode()
        {
            return Person.Name.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            return Equals(obj as PersonShoe);
        }

        public bool Equals(PersonShoe other)
        {
            if (other == null) return false;
            if (other.GetType() != GetType()) return false;
            return Person.Equals(other.Person) && Shoe.Equals(other.Shoe);
        }

        public override string ToString()
        {
            return String.Format("{0} {1}", Person, Shoe);
        }
    }
}
